/**
 * 
 */
package edu.hm.compiler.scanner.token;

import edu.hm.compiler.I18NCompiler;

/**
 * @author Saruman
 */
public class TokenClass implements ITokenClass
{
    @Override
    public int hashCode()
    {
        final int prime = 31;
        int result = 1;
        result = prime * result + ( ( this.name == null ) ? 0 : this.name.hashCode() );
        return result;
    }

    @Override
    public boolean equals( Object obj )
    {
        if( this == obj )
        {
            return true;
        }
        if( obj == null )
        {
            return false;
        }
        if( getClass() != obj.getClass() )
        {
            return false;
        }
        TokenClass other = (TokenClass) obj;
        if( this.name == null )
        {
            if( other.name != null )
            {
                return false;
            }
        } else if( !this.name.equals( other.name ) )
        {
            return false;
        }
        return true;
    }

    private final String name;

    /**
     * @param name
     * @param isVariable
     */
    public TokenClass( String name )
    {
        if( name == null )
            throw new IllegalArgumentException( I18NCompiler.getString("NameNotNull") ); //$NON-NLS-1$
        this.name = name;
    }

    /*
     * (non-Javadoc)
     * @see edu.hm.compiler.token.ITokenClass#getName()
     */
    @Override
    public String getName()
    {
        return this.name;
    }

    @Override
    public String toString()
    {
        return "TokenClass [name=" + name + "]"; //$NON-NLS-1$ //$NON-NLS-2$
    }

}
